#!/bin/bash

#------------------------------------------------------------------------------
#Filename:      LV.sh
#Version:       1.0
#Date:          2014/06/25
#Author:        xi.zhang
#Email:         xi.zhang@cs2c.com.cn
#Summary:       逻辑卷操作：创建和删除
#Notes:         对逻辑卷的一组操作
#Copyright:     China Standard Software Co.,Ltd.
#History:
#               Version 1.0,2014/06/25
#               -The first one
#------------------------------------------------------------------------------


##! @TODO: Create Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateLV()
{    
   lvcreate -L ${LVSIZE}G -n ${LVNAME} ${VGNAME}
}


##! @TODO: Delete Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function DeleteLV()
{
    lvremove -f ${VGNAME}/${LVNAME}
}


##! @TODO: Create snap of Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateLVsnap()
{
    lvcreate -L ${LSSIZE}m -s -n ${LSNAME} ${LVPATH}
}


##! @TODO: Delete snap of Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function DeleteLVsnap()
{
    lvremove -f ${LSPATH}
}

##! @TODO: Create Raid1 Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateRaid1LV()
{
    lvcreate --type raid1 -m 1 -L ${LVSIZE}G -n ${LVNAME} ${VGNAME}
}


##! @TODO: Create Raid Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateRaidLV()
{
    lvcreate --type ${LVTYPE} -i ${STRIPE} -L ${LVSIZE}G -n ${LVNAME} ${VGNAME}
}


##! @TODO: Create Mirror Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateMirrorLV()
{
    lvcreate -L ${LVSIZE} -m1 -n ${LVNAME} ${VGNAME}
}


##! @TODO: Create Thinly Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function CreateThinLV()
{
    lvcreate -L ${LSIZE}m -T ${THPATH} -V${VSIZE}G -n ${LVNAME}
}


##! @TODO: Delete Thinly Logical Volume.
##! @AUTHOR: xi.zhang
##! @VERSION: 1.0 
##! @OUT:0 => success; 1 => failure.

function DeleteThinLV()
{
    lvremove -f ${VGNAME}/${LVNAME}
    lvremove -f ${VGNAME}/${LVTHIN}
}
